<template>
  <FSection title="菜单夹属性" style="padding-top: 20px">
    <div style="padding-right: 30px" v-loading="loading">
      <el-form ref="form" label-width="120px" :model="folderMenu">
        <el-form-item prop="menuName" label="菜单名称" :rules="[required]">
          <el-input v-focus placeholder="请输入菜单名称" v-model="folderMenu.menuName"/>
        </el-form-item>
      </el-form>
      <div style="text-align: right">
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </div>
  </FSection>
</template>

<script>
import {DefaultAppMenuDefinition} from '@/components/form/DefaultFormDefinition';
import {required} from '@/utils/CommonUtils';
import {putAction} from '@/request/BaseRequest';
import FSection from '@/components/FSection/index.vue';

export default {
  name: 'AppFolderMenuProperty',
  components: {
    FSection,
  },
  data() {
    return {
      loading: false,
      required,
      folderMenu: DefaultAppMenuDefinition
    };
  },
  methods: {
    setData(selectedAppMenu) {
      this.folderMenu = JSON.parse(JSON.stringify(selectedAppMenu));
    },
    save() {
      this.$refs.form.validate((valid, errors) => {
        if (valid) {
          this.doSave();
        }
      });
    },
    doSave() {
      this.loading = true;
      putAction('/plat/platAppMenu/save', this.folderMenu).then(data => {
        if (data.success) {
          this.$message.success('保存成功')
          this.$emit('reload');
        } else {
          this.$notification.error({message: data.message, duration: 3});
        }
        this.loading = false;
      })
    },
  }
};
</script>

